#include <iostream>
#include <cmath>
using namespace std;
using ll=long long;
bool check(ll num){
	
	for(int i=2;i<=sqrt(num);++i){
		if(num%i==0){
			return false;
		}
	}
	return true;
}
int main() {

	int t;
	cin>>t;
	while(t--){
		ll a,b;
		cin>>a>>b;
		if(a==1 || b==1){
			if(a!=1 && check(a)|| b!=1 && check(b)){
				cout<<"YES"<<endl;
			}
			else{
				cout<<"NO"<<endl;
			}
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	
	return 0;
}
